const data= require('../../../../lib/data')
const result = require('../../../../lib/result')
const setup = require('../../../../controller/setup')
class ventilate {
   static async send(ctx) {

    let array = await setup.areas(ctx); 
    const command = Buffer.from([0xA0, 0x04]);
    const raw = Buffer.from([array.length, 0].concat(array));
    //const raw = Buffer.from([0x01, 0x00, 0x01]);
    ctx.state.socket.write(data.pack(command, raw));
    result.time =  (new Date()).getTime();
    result.succeed = true;
    return result
  }
}

module.exports = ventilate